#!/bin/bash
old=`cat /var/lib/zerotier-one/moons.d/old.txt`
cur=`curl ifconfig.me`
echo $old $cur
if  [ $old == $cur ]
then
    echo '两个IP相等!'
else
    echo "两个IP不相等!"
    sed -i "s/$old/$cur/g"  moon.json
    zerotier-idtool genmoon moon.json
    systemctl restart zerotier-one.service
    echo $cur>/var/lib/zerotier-one/moons.d/old.txt    
fi
